package com.test;

import com.google.hello.R;

import android.app.Activity;
import android.gesture.GestureOverlayView;
import android.gesture.GestureOverlayView.OnGestureListener;
import android.os.Bundle;
import android.util.Log;
import android.view.GestureDetector;
import android.view.MotionEvent;

public class TouchDemoActivity extends Activity implements OnGestureListener, android.view.GestureDetector.OnGestureListener {
    
    private GestureDetector gestureDetector;
    
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        gestureDetector = new GestureDetector(this);
        setContentView(R.layout.main);
    }
    
    @Override
    public boolean onTouchEvent(MotionEvent me) {
        return gestureDetector.onTouchEvent(me);
    }
    
    @Override
    public boolean onDown(MotionEvent e) {
        Log.d("googleTouch1", "onDown");
        return true;
    }

    @Override
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
            float velocityY) {
        Log.d("googleTouch1", "onFling: velX="+velocityX+" velY="+velocityY);
        return true;
    }

    @Override
    public void onLongPress(MotionEvent e) {
        Log.d("googleTouch1", "onLongPress");
    }

    @Override
    public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
            float distanceY) {
        Log.d("googleTouch1", "onScroll: disX="+distanceX+" disY="+distanceY);
        return true;
    }

    @Override
    public void onShowPress(MotionEvent e) {
        Log.d("googleTouch1", "onShowPress");
    }

    @Override
    public boolean onSingleTapUp(MotionEvent e) {
        Log.d("googleTouch1", "onSingleTapUp");
        return true;
    }
    
    @Override
    public void onGesture(GestureOverlayView overlay, MotionEvent event) {
        Log.d("googleTouch", "Gesture");
    }

    @Override
    public void onGestureCancelled(GestureOverlayView overlay, MotionEvent event) {
        Log.d("googleTouch", "GestureCancelled");       
    }

    @Override
    public void onGestureEnded(GestureOverlayView overlay, MotionEvent event) {
        Log.d("googleTouch", "GestureEnded");       
    }

    @Override
    public void onGestureStarted(GestureOverlayView overlay, MotionEvent event) {
        Log.d("googleTouch", "GestureStarted");     
    }
}